package com.wangyadong.hobby.parrent.dyproxy;

import com.wangyadong.hobby.admin.servcie.IAnswerService;
import com.wangyadong.hobby.admin.servcie.impl.AnswerServiceImpl;
import com.wangyadong.hobby.common.service.TestInterface;
import com.wangyadong.hobby.common.service.impl.TestInterfaceImpl;

import java.lang.reflect.Proxy;

public class Main {

    public static void main(String[] args) {
        TestInterface testInterface1 = new TestInterfaceImpl();
        ClassLoader classLoader = testInterface1.getClass().getClassLoader();

        Class<?>[] interfaces = testInterface1.getClass().getInterfaces();
        TestProxy testProxy = new TestProxy(testInterface1);
        TestInterface testInterface = (TestInterface) Proxy.newProxyInstance(classLoader, interfaces, testProxy);

        testInterface.before();
        testInterface.after();
    }
}
